## hand work .... hard work ... I need Cmake !!!!!! fuck

CXX = cl
CXXFLAGS = /utf-8 /EHsc /Zi /Od /Fd$(OBJ_DIR)/ 
LDFLAGS = /link /DEBUG user32.lib gdi32.lib kernel32.lib # 添加了就可以DEBUG


BIN_DIR = bin
OBJ_DIR = obj
SRC_TEST = src/test
SRC_MESH = src/mesh
SRC_CAMERA = src/camera
SRC_DEVICE = src/device
SRC_PERSPECTIVE = src/perspective
SRC_DRAWER = src/drawer

allBin: $(BIN_DIR)/test.exe $(BIN_DIR)/winTest.exe $(BIN_DIR)/dotModel.exe $(BIN_DIR)/modelTest.exe

## test, render, testWin
$(BIN_DIR)/test.exe: $(OBJ_DIR)/test.obj | $(BIN_DIR)
	$(CXX) $(CXXFLAGS) /Fe:$(BIN_DIR)/test.exe $(OBJ_DIR)/test.obj

$(BIN_DIR)/winTest.exe: $(OBJ_DIR)/winTest.obj $(OBJ_DIR)/mesh.obj $(OBJ_DIR)/drawer.obj $(OBJ_DIR)/device.obj $(OBJ_DIR)/perspective.obj $(OBJ_DIR)/camera.obj | $(BIN_DIR)
	$(CXX) $(CXXFLAGS) /Fe:$(BIN_DIR)/winTest.exe $(OBJ_DIR)/winTest.obj $(OBJ_DIR)/mesh.obj $(OBJ_DIR)/drawer.obj $(OBJ_DIR)/device.obj $(OBJ_DIR)/perspective.obj $(OBJ_DIR)/camera.obj $(LDFLAGS)

$(BIN_DIR)/dotModel.exe: $(OBJ_DIR)/dotModel.obj $(OBJ_DIR)/mesh.obj $(OBJ_DIR)/drawer.obj $(OBJ_DIR)/device.obj $(OBJ_DIR)/perspective.obj $(OBJ_DIR)/camera.obj | $(BIN_DIR)
	$(CXX) $(CXXFLAGS) /Fe:$(BIN_DIR)/dotModel.exe $(OBJ_DIR)/dotModel.obj $(OBJ_DIR)/mesh.obj $(OBJ_DIR)/drawer.obj $(OBJ_DIR)/device.obj $(OBJ_DIR)/perspective.obj $(OBJ_DIR)/camera.obj $(LDFLAGS)

$(BIN_DIR)/modelTest.exe: $(OBJ_DIR)/modelTest.obj $(OBJ_DIR)/mesh.obj $(OBJ_DIR)/drawer.obj $(OBJ_DIR)/device.obj $(OBJ_DIR)/perspective.obj $(OBJ_DIR)/camera.obj | $(BIN_DIR)
	$(CXX) $(CXXFLAGS) /Fe:$(BIN_DIR)/modelTest.exe $(OBJ_DIR)/modelTest.obj $(OBJ_DIR)/mesh.obj $(OBJ_DIR)/drawer.obj $(OBJ_DIR)/device.obj $(OBJ_DIR)/perspective.obj $(OBJ_DIR)/camera.obj $(LDFLAGS)

## The rest are object files. Below this line. Except for test, which will be divided into two, I will package everything in a folder into one .o. Manual management is too much trouble. I don't want to manage manually. I must learn CMake in the future.

$(OBJ_DIR)/test.obj: $(SRC_TEST)/test.cpp | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) /c $(SRC_TEST)/test.cpp /Fo:$(OBJ_DIR)/test.obj

$(OBJ_DIR)/winTest.obj: $(SRC_TEST)/winTest.cpp | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) /c $(SRC_TEST)/winTest.cpp /Fo:$(OBJ_DIR)/winTest.obj

$(OBJ_DIR)/dotModel.obj: $(SRC_TEST)/dotModel.cpp | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) /c $(SRC_TEST)/dotModel.cpp /Fo:$(OBJ_DIR)/dotModel.obj

$(OBJ_DIR)/modelTest.obj: $(SRC_TEST)/modelTest.cpp | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) /c $(SRC_TEST)/modelTest.cpp /Fo:$(OBJ_DIR)/modelTest.obj

$(OBJ_DIR)/perspective.obj: $(SRC_PERSPECTIVE)/dot.cpp $(SRC_PERSPECTIVE)/calculate.cpp | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) /c $(SRC_PERSPECTIVE)/dot.cpp /Fo:$(OBJ_DIR)/dot.obj
	$(CXX) $(CXXFLAGS) /c $(SRC_PERSPECTIVE)/calculate.cpp /Fo:$(OBJ_DIR)/calculate.obj
	lib /OUT:$(OBJ_DIR)/perspective.obj $(OBJ_DIR)/dot.obj $(OBJ_DIR)/calculate.obj

$(OBJ_DIR)/mesh.obj: $(SRC_MESH)/dotMatrix.cpp $(SRC_MESH)/model.cpp | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) /c $(SRC_MESH)/dotMatrix.cpp /Fo:$(OBJ_DIR)/dotMatrix.obj
	$(CXX) $(CXXFLAGS) /c $(SRC_MESH)/model.cpp /Fo:$(OBJ_DIR)/model.obj
	lib /OUT:$(OBJ_DIR)/mesh.obj $(OBJ_DIR)/model.obj $(OBJ_DIR)/dotMatrix.obj


$(OBJ_DIR)/drawer.obj: $(SRC_DRAWER)/draw.cpp | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) /c $(SRC_DRAWER)/draw.cpp /Fo:$(OBJ_DIR)/drawer.obj

$(OBJ_DIR)/camera.obj: $(SRC_CAMERA)/camera.cpp | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) /c $(SRC_CAMERA)/camera.cpp /Fo:$(OBJ_DIR)/camera.obj

$(OBJ_DIR)/device.obj: $(SRC_DEVICE)/myMatrix.cpp $(SRC_DEVICE)/rotation.cpp $(SRC_DEVICE)/depth.cpp | $(OBJ_DIR)
	$(CXX) $(CXXFLAGS) /c $(SRC_DEVICE)/rotation.cpp /Fo:$(OBJ_DIR)/rotation.obj
	$(CXX) $(CXXFLAGS) /c $(SRC_DEVICE)/myMatrix.cpp /Fo:$(OBJ_DIR)/myMatrix.obj
	$(CXX) $(CXXFLAGS) /c $(SRC_DEVICE)/depth.cpp /Fo:$(OBJ_DIR)/depth.obj
	lib /OUT:$(OBJ_DIR)/device.obj $(OBJ_DIR)/rotation.obj $(OBJ_DIR)/myMatrix.obj $(OBJ_DIR)/depth.obj

.PHONY: clean
clean:
	-del /Q $(OBJ_DIR)\*.obj
	-del /Q $(BIN_DIR)\*.exe